home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 224_01 / expr.hlp < prev    next >
Encoding:
Text File  |  1987-01-04  |  2.4 KB  |  76 lines

  1. NAME
  2.      expr - evaluate arguments as an expression
  3.  
  4. SYNTAX
  5.      expr [-v] [arg] ...
  6.  
  7. DESCRIPTION
  8.      The arguments are taken as an expression.  After evaluation,
  9.      the result is written on the standard output.  
  10.  
  11.      If the -v option is present the result is printed in decimal, octal 
  12.      and hexadecimal form, and the unsigned equilavence in long, int, 
  13.      and char is also output if the result is negative.
  14.  
  15.      If arguments are missing on the command line, then arguments are
  16.      taken from the standard input.  Each line is processed separately.
  17.  
  18.      The operators and keywords are listed below.  The list is in
  19.      order of increasing precedence, with equal precedence operators 
  20.      grouped.
  21.  
  22.      expr : expr
  23.           yields the first expr if it is not zero, otherwise
  24.           yields the second expr.  Note that the ':' is the colon.
  25.  
  26.      expr & expr
  27.           yields the first expr if neither expr is zero,
  28.           otherwise yields '0'.
  29.  
  30.      expr relop expr
  31.           where relop is one of LT LE NE EQ GE GT, yields '1' if the
  32.           indicated comparison is true, '0' if false.
  33.  
  34.      expr + expr
  35.      expr - expr
  36.           addition or subtraction of the arguments.
  37.  
  38.      expr * expr
  39.      expr / expr
  40.      expr % expr
  41.           multiplication, division, or remainder of the arguments.
  42.  
  43.      ! expr
  44.      - expr
  45.           unary logic negation (!) or numeric negation (-) of the argument.
  46.  
  47.      ( expr )
  48.           parentheses for grouping.
  49.  
  50.      #
  51.      #n
  52.          recalls the previous answers for n = 0-9 and # is #0 (last result).
  53.          This is only useful if the arguments are taken from the standard
  54.          input.
  55.      
  56. EXAMPLE
  57.      expr "45 * 32 / 2"
  58.      expr 200+20-45 & 64 / 65
  59.      expr 5 gt $LASTNUM
  60.     
  61. DIAGNOSTICS
  62.      Expr returns the following exit codes:
  63.           0    if the expression is neither null nor '0',
  64.           1    if the expression is null or '0',
  65.           2    for invalid expressions.
  66.  
  67. SEE ALSO
  68.      test, hoc
  69.  
  70. RESTRICTIONS
  71.      The result is a long integer and all the arguments have to be integers
  72.      or characters ('...').  On the command line, the character quotes ( ' )
  73.      have to be escaped (\') so they won't be removed.  The multiplication 
  74.      sign (*) has to be enclosed in quotes on the command line so file names 
  75.      are not generated. 
  76.